<?php
namespace App\Models\Requests;

class UserRequest extends BaseRequest
{
    public function rules()
    {
        switch ($this->method()) {
            case 'GET':
                {
                    return [
                        'id' => ['required']
                    ];
                }
            case 'POST':
                {
                    return [
                        'name' => ['required', 'string', 'max:60','min:4','unique:users,name'],
                        'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
                        'password' => ['required', 'string', 'max:60', 'min:6', 'confirmed'],
                    ];
                }
            case 'PUT':
            case 'PATCH':
            case 'DELETE':
            default:
                {
                    return [

                    ];
                }
        }
    }

    public function messages()
    {
        return [
            'id.required' => '用户ID必须填写',
            'id.exists' => '用户不存在',
            'name.unique' => '用户名已经存在',
            'name.required' => '用户名不能为空',
            'name.max' => '用户名最大长度为60个字符',
            'name.min' => '用户名最小长度为4个字符',
            'email.unique' => 'Email已经存在',
            'email.max' => 'Email长度不能超过255个字符',
            'password.required' => '密码不能为空',
            'password.max' => '密码长度不能超过60个字符',
            'password.min' => '密码长度不能小于6个字符',
        ];
    }
}
